package com.tom.web;

import com.tom.domain.Product;
import com.tom.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author yanghongjun19
 * @date 2021/01/06
 **/


@RestController
@RequestMapping("/product")
@Slf4j
public class ProductController {

    @Resource
    private IProductService productService;

    @RequestMapping("/save")
    public String save(Product product) throws Exception {
        productService.save(product);
        return "success";
    }

    @RequestMapping("/get")
    public Product get(Long id) throws Exception {
        log.info("请求的id=" + id);
        Product product = productService.get(id);
        return product;
    }

}
